package model.market;

public class BetaMarketRetFinanceCharge implements FinanceCharge{

	public double getPeriodFinanceCharge(Position pos,
			MarketInformation info, MarketManager manager,double currentRiskFree, double indexDivYield, double indexCapitalReturn) {
		
		double requiredReturn = currentRiskFree;
		
		if(info.getIndexPrices().size()!=0){
			requiredReturn = (currentRiskFree/manager.getConfig().getPeriodsInYear())+
				(pos.getBeta(info.getMarketPrices(), info.getAssetBetas())*
						(indexCapitalReturn+((indexDivYield-currentRiskFree)/manager.getConfig().getPeriodsInYear())));
		}
		
		double financeCharge =-requiredReturn*pos.getWorth(info.getMarketPrices());
		
		return financeCharge;
	}
}
